#ifndef AutoLocker_h__
#define AutoLocker_h__
#include "SectionLocker.h"

namespace gee
{
	class AutoLocker
	{
		SectionLocker& _s;
		bool acquired;
	public:
		AutoLocker(SectionLocker& s):_s(s),acquired(true)
		{
			_s.lock();
		}
		~AutoLocker()
		{
			if(acquired)
				_s.unlock();
		}

		void lock()
		{
			assert(acquired==false);
			acquired=true;
			_s.lock();
		}
		void unlock()
		{
			assert(acquired==true);
			acquired=false;
			_s.unlock();
		}

	};
}
#endif // AutoLocker_h__